#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  This window displays usable skills on the skill and battle screens.
#==============================================================================

class Window_Innate_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 640, 352)
    @actor = actor
    @column_max = 1
    refresh
    self.index = 0
    @_item_height = 64
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @actor.innate_skills.size
    if @item_max > 0
      self.contents = Bitmap.new(self.width - 10, row_max * 64)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  def skill
    return @actor.innate_skills[self.index]
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @actor.innate_skills[index]
    type_text = ''
    case skill.type
      when 1
        type_text = '普通攻击'
      when 2
        type_text = '战  技'
      when 3
        type_text = '特殊天赋'
      when 4
        type_text = '终 结 技'
    end
    x = 0
    y = index * 64
    width = self.width
    rect = Rect.new(x, y, width, 64)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x + 2, y + 2, bitmap, Rect.new(0, 0, 60, 60), opacity)
    self.contents.draw_text(x + 68, y, 64, @_item_height, skill.name, 0)
    self.contents.draw_text(x + 264, y, 48, @_item_height, "等级：" + skill.level.to_s, 2)
    self.contents.draw_text(x + 340, y, 48, @_item_height, type_text, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end
